<script setup>
import { ref } from 'vue';
import { getUserInfo } from '@/api/user.js'
import { useRouter, useRoute } from 'vue-router'
import { ElMessage } from 'element-plus'
const router = useRouter()
const route = useRoute()
let phone = ref('')
let password = ref('')
let userDto = ref({
    phone: '',
    password: ''
})
const userLogin = async () => {
    userDto.value.phone = phone.value
    userDto.value.password = password.value
    const res = await getUserInfo(userDto.value)
    if (res.code != 1) {
        ElMessage.error(res.msg)
        return
    }
    console.log(res)
    localStorage.setItem('token', res.data.token)
    if (res.code === 1) {
        router.replace('/home/user')
    }
}
</script>
<template>
    <div class="box">
        <h1 class="title">湖南日永州分社报绩效考核后台系统</h1>
        <div class="box-login">

            <div class="box-login-box">
                <h2>
                    手机号：<el-input v-model="phone" style="width: 240px" placeholder="请输入手机号" />
                </h2>

                <h2 style="margin-top: 30px;">
                    &nbsp;&nbsp;&nbsp;密码：<el-input v-model="password" style="width: 240px" placeholder="请输入密码" />
                </h2>
            </div>
            <el-button type="primary" class="button" @click="userLogin()">登录</el-button>
        </div>
    </div>
</template>

<style scoped lang="less">
.box {
    width: 100%;
    height: 100vh;

}

.box-login {
    width: 700px;
    height: 400px;
    background-color: #b8b4b4;
    border-radius: 10px;
    margin: 0 auto;
    margin-top: 50px;
    padding-top: 30px;

}

.title {
    font-size: 40px;
    color: #0b0b0b;
    margin-top: 100px;
    text-align: center;
}

.box-login-box {
    margin-top: 100px;
    margin-left: 130px;
}

.button {
    margin-top: 50px;
    margin-left: 260px;
    width: 120px;
    height: 60px;
    font-size: 20px;
}
</style>
